package com.example.warehousems.vo;

import com.alibaba.fastjson.JSON;
import com.example.warehousems.dao.model.Cargo;
import com.example.warehousems.dao.model.User;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

@Data
public class JobTicketVO {
    @NotEmpty(message = "缺少联系人姓名")
    private String contactName;
    @NotEmpty(message = "缺少联系方式")
    private String phoneNum;
    @NotNull(message = "缺少待入库货物")
    private List<CargoVO> cargoList;
    @NotNull(message = "缺少预计入库时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime estimateTime;

    @Override
    public String toString() {
        return "{" +
                "\"contactName\":\"" + contactName + '"' +
                ", \"phoneNum\":\"" + phoneNum + '"' +
                ", \"cargoList\":" + JSON.toJSONString(cargoList) +
                ", \"estimateTime\":\"" + estimateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) +
                "\"}";
    }
}
